﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FluorineFx;
using System.Data;
using System.Security.Principal;
using System.Collections;
using WebKpiPage.Data;
using WebKpiPage;
using WebKpiPage.Data.GongdanMgr;
using WebKpiPage.BLL.GongdanMgr;
using Model;
using Model.GongDanMgr;
namespace RemoteFlunorineFx.GongdanMgr
{
    [RemotingService]
    [Description("Customer data service")]
    public class GongdanModule
    {

        [DataTableType("Flex.GongdanModule")]
        public ArrayList GetGongdanListByUserId(string userId,int status)
        {
            DataSet ds = GongdanMgrCls.GetDongdanRecordByUserId(userId,status);
            ArrayList array = new ArrayList();

            if (ds != null && ds.Tables != null)
            {
                for (int i = 0; i < ds.Tables.Count; i++)
                {
                    array.Add(ds.Tables[i]);
                }
                return array;
            }
            return null;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="proj"></param>
        /// <param name="type">1:派单，2：打回指派的单，3：处理工单,4:申请延期工单的回复，5:申请延期</param>
        /// <param name="requestDayNums">申请延期天数</param>
        /// <param name="status">0：反对，1：同意</param>
        /// <returns></returns>
        public bool DelwithGongdan(GongDanProj proj,int type,int requestDayNums)
        {
            int rtn = 0;
            switch (type)
            {
                case 1:
                    rtn = WebKpiPage.BLL.GongdanMgr.GongdanLogic.PaiDanContinue(proj);
                    break;
                case 2:
                   // rtn = WebKpiPage.BLL.GongdanMgr.GongdanLogic.Reject(new Guid(currentUser), proj.FK_User_责任人, proj.WorkflowInstanceId, proj.ID, proj.ActivityId);
                    rtn = WebKpiPage.BLL.GongdanMgr.GongdanLogic.Reject(proj);
                    break;
                case 3:
                    rtn = WebKpiPage.BLL.GongdanMgr.GongdanLogic.Chuli(proj);
                   break;
                case 4://
                   rtn = WebKpiPage.BLL.GongdanMgr.GongdanLogic.RequestMoreTime(proj, requestDayNums);
                   break;
                case 5://
                   rtn = WebKpiPage.BLL.GongdanMgr.GongdanLogic.RequestDelwith(proj, 0);
                    break;
                case 6://
                    rtn = WebKpiPage.BLL.GongdanMgr.GongdanLogic.RequestDelwith(proj, 1);
                    break;
               
                default:
                    break;
            }
            
            return rtn > 0 ? true : false;
        }
        public bool UpdateGongdanRecord(GongDanProj proj)
        {
            return GongdanMgrCls.UpdateGongdanRecord(proj);
        }
        public DataTable GetUserInfoByUserId(string userId)
        {
            return UserMgr.GetUserInfoByUserId(new Guid(userId));
        }

        #region 任务查询
        [DataTableType("")]
        public DataSet GetAllTask(AllTaskParamItem param)
        {
            return GongdanMgrCls.GetAllTask(param);
        }
        #endregion


    }
}
